﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Collections;
public partial class zoushitu_dlt_dlt_qqws : System.Web.UI.Page
{
    protected List<Model.LotteryAnnouncement> arlist = null;
    protected string[] SSQList = null;
    protected string SSQblue = null;
    protected int jinqiCount = 0;

    protected DataTable dtPaperList = new DataTable();  //尾数汇总 
    protected Hashtable dt_tiao = new Hashtable();//统计0-9格式

    protected void Page_Load(object sender, EventArgs e)
    {
        ZoushiManage.FangWenZouShi();
        if (!IsPostBack)
        {
            jinqiCount = 30;
            bindData(30);
        }
    }

    protected void bindData(int maxValue)
    {
        arlist = BLL.LotteryAnnouncement.getDatasDesc(maxValue,2);

        if (arlist != null)
        {
            #region
            dtPaperList.Columns.Add("Hezhi0", typeof(string));
            dtPaperList.Columns.Add("Hezhi1", typeof(string));
            dtPaperList.Columns.Add("Hezhi2", typeof(string));
            dtPaperList.Columns.Add("Hezhi3", typeof(string));
            dtPaperList.Columns.Add("Hezhi4", typeof(string));
            dtPaperList.Columns.Add("Hezhi5", typeof(string));
            dtPaperList.Columns.Add("Hezhi6", typeof(string));
            dtPaperList.Columns.Add("Hezhi7", typeof(string));
            dtPaperList.Columns.Add("Hezhi8", typeof(string));
            dtPaperList.Columns.Add("Hezhi9", typeof(string));
            dt_tiao.Add("0", 0);
            dt_tiao.Add("1", 0);
            dt_tiao.Add("2", 0);
            dt_tiao.Add("3", 0);
            dt_tiao.Add("4", 0);
            dt_tiao.Add("5", 0);
            dt_tiao.Add("6", 0);
            dt_tiao.Add("7", 0);
            dt_tiao.Add("8", 0);
            dt_tiao.Add("9", 0);
            int w0 = 0, w1 = 0, w2 = 0, w3 = 0, w4 = 0, w5 = 0, w6 = 0, w7 = 0, w8 = 0, w9 = 0;
            #endregion
            for (int i = 0; i < arlist.Count; i++)
            {
                string[] redBall = arlist[i].LotteryNo.Split('+')[0].Split(',');
                for (int m = 0; m < redBall.Length; m++)
                {
                    //计算条形图中每个数的个数红球
                    bindTiaoxing(0, int.Parse(redBall[m]));
                }
                bindWs(redBall);

                #region
                string ws0 = dtPaperList.Rows[i][0].ToString();
                string ws1 = dtPaperList.Rows[i][1].ToString();
                string ws2 = dtPaperList.Rows[i][2].ToString();
                string ws3 = dtPaperList.Rows[i][3].ToString();
                string ws4 = dtPaperList.Rows[i][4].ToString();
                string ws5 = dtPaperList.Rows[i][5].ToString();
                string ws6 = dtPaperList.Rows[i][6].ToString();
                string ws7 = dtPaperList.Rows[i][7].ToString();
                string ws8 = dtPaperList.Rows[i][8].ToString();
                string ws9 = dtPaperList.Rows[i][9].ToString();
                if (ws0.ToString() != "")
                {
                    if (int.Parse(ws0) > 1)
                    {
                        w0 = w0 + int.Parse(ws0);
                    }
                    else
                    {
                        w0 = w0 + 1;

                    }
                    dt_tiao["0"] = w0;
                }
                if (ws1.ToString() != "")
                {
                    if (int.Parse(ws1) > 1)
                    {
                        w1 = w1 + int.Parse(ws1);
                    }
                    else
                    {
                        w1 = w1 + 1;
                    }
                    dt_tiao["1"] = w1;
                }
                if (ws2.ToString() != "")
                {
                    if (int.Parse(ws2) > 1)
                    {
                        w2 = w2 + int.Parse(ws2);
                    }
                    else
                    {
                        w2 = w2 + 1;
                    }
                    dt_tiao["2"] = w2;
                }
                if (ws3.ToString() != "")
                {
                    if (int.Parse(ws3) > 1)
                    {
                        w3 = w3 + int.Parse(ws3);
                    }
                    else
                    {
                        w3 = w3 + 1;
                    }
                    dt_tiao["3"] = w3;
                }
                if (ws4.ToString() != "")
                {
                    if (int.Parse(ws4) > 1)
                    {
                        w4 = w4 + int.Parse(ws4);
                    }
                    else
                    {
                        w4 = w4 + 1;
                    }
                    dt_tiao["4"] = w4;
                }
                if (ws5.ToString() != "")
                {
                    if (int.Parse(ws5) > 1)
                    {
                        w5 = w5 + int.Parse(ws5);
                    }
                    else
                    {
                        w5 = w5 + 1;
                    }
                    dt_tiao["5"] = w5;
                }
                if (ws6 != "")
                {
                    if (int.Parse(ws6) > 1)
                    {
                        w6 = w6 + int.Parse(ws6);
                    }
                    else
                    {
                        w6 = w6 + 1;
                    }
                    dt_tiao["6"] = w6;
                }
                if (ws7 != "")
                {
                    if (int.Parse(ws7) > 1)
                    {
                        w7 = w7 + int.Parse(ws7);
                    }
                    else
                    {
                        w7 = w7 + 1;
                    }
                    dt_tiao["7"] = w7;
                }
                if (ws8 != "")
                {
                    if (int.Parse(ws8) > 1)
                    {
                        w8 = w8 + int.Parse(ws8);
                    }
                    else
                    {
                        w8 = w8 + 1;
                    }
                    dt_tiao["8"] = w8;
                }
                if (ws9 != "")
                {
                    if (int.Parse(ws9) > 1)
                    {
                        w9 = w9 + int.Parse(ws9);
                    }
                    else
                    {
                        w9 = w9 + 1;
                    }
                    dt_tiao["9"] = w9;
                }
                #endregion

            }
        }
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        jinqiCount = int.Parse(DropDownList1.SelectedValue);
        bindData(int.Parse(DropDownList1.SelectedValue));
    }
    /// <summary>
    /// 计算尾数
    /// </summary>
    /// <param name="data">对应红球的号码</param>
    void bindWs(string[] redBall)
    {
        DataRow newRow = dtPaperList.NewRow();
        for (int m = 0; m < redBall.Length; m++)
        {
            int data = int.Parse(redBall[m].Substring(redBall[m].Length - 1, 1));
            for (int i = 0; i < 10; i++)
            {  
                if (data == i)
                {
                    string aa = newRow["Hezhi" + i].ToString();
                    if (aa == "")
                    {
                        newRow["Hezhi" + i] = "0";
                    }
                    int a = int.Parse(newRow["Hezhi" + i].ToString());

                    newRow["Hezhi" + i] = (a + 1).ToString();

                }
            }
        }
        dtPaperList.Rows.Add(newRow);
    }
    /// <summary>
    /// 计算红篮球的出现个数
    /// </summary>
    /// <param name="type">0 红球 1 蓝球</param>
    /// <param name="data">对应球的号码</param>
    protected int[] TiaoxingDT = new int[47];
    protected void bindTiaoxing(int type, int data)
    {
        for (int i = 0; i < 47; i++)
        {
            if (type == 0)
            {
                if (data == (i + 1))
                {
                    TiaoxingDT[i] += 1;
                }
            }
            if (type == 1)
            {
                if (data == (i + 1 - 35))
                {
                    TiaoxingDT[i] += 1;
                }
            }
        }
    }
}